]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
status/keyboard: implement remaining property types
authorGiovanni Campagna <gcampagna@src.gnome.org>
Sat, 24 Nov 2012 14:56:06 +0000 (15:56 +0100)
committerGiovanni Campagna <gcampagna@src.gnome.org>
Thu, 13 Dec 2012 23:47:19 +0000 (00:47 +0100)
Input methods other than Anthy need different property types, so we
should support all those exposed by the IBus protocol.

https://bugzilla.gnome.org/show_bug.cgi?id=682318

js/ui/status/keyboard.js

index f12c787d5aa48fb21956a76353c8a7f8595ed3ad..cf036ac57219445db2f37d3521dcbb90e3191bb2 100644 (file)
@@ -484,11 +484,13 @@ const InputSourceIndicator = new Lang.Class({
             }
 
             let item;
-            let type = prop.get_prop_type();
-            if (type == IBus.PropType.MENU) {
+            switch (prop.get_prop_type()) {
+            case IBus.PropType.MENU:
                 item = new PopupMenu.PopupSubMenuMenuItem(prop.get_label().get_text());
                 this._buildPropSubMenu(item.menu, prop.get_sub_props());
-            } else if (type == IBus.PropType.RADIO) {
+                break;
+
+            case IBus.PropType.RADIO:
                 item = new PopupMenu.PopupMenuItem(prop.get_label().get_text());
                 item.prop = prop;
                 radioGroup.push(item);
@@ -513,7 +515,39 @@ const InputSourceIndicator = new Lang.Class({
                         }
                     }
                 }));
-            } else {
+                break;
+
+            case IBus.PropType.TOGGLE:
+                item = new PopupMenu.PopupSwitchMenuItem(prop.get_label().get_text(), prop.get_state() == IBus.PropState.CHECKED);
+                item.prop = prop;
+                item.connect('toggled', Lang.bind(this, function() {
+                    if (item.state) {
+                        item.prop.set_state(IBus.PropState.CHECKED);
+                        this._ibusManager.activateProperty(item.prop.get_key(),
+                                                           IBus.PropState.CHECKED);
+                    } else {
+                        item.prop.set_state(IBus.PropState.UNCHECKED);
+                        this._ibusManager.activateProperty(item.prop.get_key(),
+                                                           IBus.PropState.UNCHECKED);
+                    }
+                }));
+                break;
+
+            case IBus.PropType.NORMAL:
+                item = new PopupMenu.PopupMenuItem(prop.get_label().get_text());
+                item.prop = prop;
+                item.connect('activate', Lang.bind(this, function() {
+                    this._ibusManager.activateProperty(item.prop.get_key(),
+                                                       IBus.PropState.CHECKED);
+                }));
+                break;
+
+            case IBus.PropType.SEPARATOR:
+                item = new PopupMenu.PopupSeparatorMenuItem();
+                break;
+
+            default:
+                log ('IBus property %s has invalid type %d'.format(prop.get_key(), type));
                 continue;
             }